import torch
import torch.nn as nn
import numpy as np
# a = np.arange(1, 13).reshape(3, 4)
# b = torch.from_numpy(a)
# input = b.float()
# print('input:\n', input)
#
# y_target = torch.tensor([1, 2, 3])
# print('y_target:\n', y_target)
#
# crossentropyloss = nn.CrossEntropyLoss(reduction='none')
# crossentropyloss_output = crossentropyloss(input, y_target)
# print('crossentropyloss_output:\n', crossentropyloss_output)
#
# softmax_func = nn.Softmax(dim=1)
# soft_output = softmax_func(input)
# print('soft_output:\n', soft_output)
# log_output = torch.log(soft_output)
# print('log_output:\n', log_output)
# # # print('log_output.shape:\n', log_output.shape)
# # # print('y_target.shape:\n', y_target.shape)
# # y_target = torch.tensor([[1, 2, 3]], dtype=torch.float)
# # nllloss_output = torch.mm(y_target, log_output)
# nllloss_func = nn.NLLLoss()  # reduction='none'
# nllloss_output = nllloss_func(log_output, y_target)
# print('nllloss_output:\n', nllloss_output)
